@extends('admin.layout.index')
@section('content')
	<div class="portlet box blue">

							<div class="portlet-title">

								<div class="caption"><i class="icon-reorder"></i>网站配置列表</div>

								<div class="tools">

									<a href="javascript:;" class="collapse"></a>

									<a href="#portlet-config" data-toggle="modal" class="config"></a>

									<a href="javascript:;" class="reload"></a>

									<a href="javascript:;" class="remove"></a>

								</div>

							</div>

							<div class="portlet-body form">

								<!-- BEGIN FORM-->

								<form action="/admin/config" method="post" enctype='multipart/form-data' class="form-horizontal" id="slide_form">
								{{csrf_field()}}
								<input type="hidden" name='id' value="{{$data['id']}}">
									<div class="control-group warning">

										<label class="control-label" for="inputWarning">标题</label>

										<div class="controls">
											<input type="text" class="span6 m-wrap" name="title" id="inputWarning" value="{{$data['title']}}">
										</div>

									</div>

									<div class="control-group warning">

										<label class="control-label" for="inputWarning">关键字</label>

										<div class="controls">
											<input type="text" class="span6 m-wrap" name="keywords" id="inputWarning" value="{{$data['keywords']}}">
										</div>

									</div>

									<div class="control-group warning">

										<label class="control-label" for="inputWarning">描述</label>

										<div class="controls">
											<!-- <input type="text" class="span6 m-wrap" name="description" id="inputWarning"> -->
											<textarea class="span6 m-wrap" name="description">{{$data['description']}}</textarea>
										</div>

									</div>

									<div class="control-group warning">

										<label class="control-label" for="inputWarning">图片</label>

										<div class="controls">
											<td>
                                    <input type="text" name="logo" id="pic" value="{{$data['logo']}}">
                                    {{--文件上传插件--}}
                                    <input id="file_upload" name="file_upload" type="file" multiple="true" >

                                    <p><img id="img1" src="/{{$data['logo']}}"  style="max-width:350px;max-height:100px;" /></p>

                            </td>
										</div>

									</div>
									@if($data['statu'])
									<div class="control-group warning">

										<label class="control-label" for="inputWarning">网站状态</label>

										<div class="controls">
											<input type="radio" name="statu" value="1"  checked>是
                                    		<input type="radio" name="statu" value="0">否
										</div>

									</div>
									@else

									<div class="control-group warning">

										<label class="control-label" for="inputWarning">是否启用</label>

										<div class="controls">
											<input type="radio" name="statu" value="1"  >是
                                    		<input type="radio" name="statu" value="0" checked>否
										</div>

									</div>
									@endif


									<div class="form-actions">

										<button type="submit" class="btn blue">修改</button>

										<button type="button" class="btn">Cancel</button>

									</div>

								</form>

								<!-- END FORM-->

							</div>

						</div>

		<script type="text/javascript">
        $(function () {
            $("#file_upload").change(function () {
                uploadImage();
            });
        });

        function uploadImage() {
  //                            判断是否有选择上传文件
            var imgPath = $("#file_upload").val();
            if (imgPath == "") {
                alert("请选择上传图片！");
                return;
            }
            //判断上传文件的后缀名
            var strExtension = imgPath.substr(imgPath.lastIndexOf('.') + 1);
            if (strExtension != 'jpg' && strExtension != 'gif'
                && strExtension != 'png' && strExtension != 'bmp') {
                alert("请选择图片文件");
                return;
            }
//                            var myform = document.getElementById('art_from');
            var formData = new FormData($('#slide_form')[0]);
            {{--formData.append('_token', '{{csrf_token()}}');--}}
                                        {{--console.log(formData);--}}
            $.ajax({
                type: "POST",
                url: "/admin/config/upload",
                data: formData,
                async: true,
                cache: false,
                contentType: false,
                processData: false,
                success: function(data) {
                                   // console.log(data);
                                   // alert("上传成功");
//                    $('#img1').attr('src','http://ovf9o4wws.bkt.clouddn.com/'+data);
//                    http://project187.oss-cn-shanghai.aliyuncs.com/uploads/201708290957357759.jpg
                   $('#img1').attr('src','/'+data);
                    $('#pic').val(data);

                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert("上传失败，请检查网络后重试");
                }
            });
        }

    </script>
@endsection